package com.itheima.entry.domain;

import java.io.Serializable;
import java.time.LocalDate;
import java.time.Period;

/*
封装学生对象
 */
public class Student implements Serializable ,Comparable<Student>{
    private static final long serialVersionUID = 68L;
    private String id;
    private String name;
    private String gender;
    private int age;
    private LocalDate birthday;
    private String phoneNum;
    private int group;
    public Student() {
    }



    public Student(String id, String name, String gender, LocalDate birthday, String phoneNum, int group) {
        this.id = id;
        this.name = name;
        this.gender = gender;
        this.birthday = birthday;
        this.phoneNum = phoneNum;
        this.group = group;
        setAge(birthday);
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public int getAge() {
        return age;
    }

    public void setAge(LocalDate birthday) {

        this.age =  Period.between(this.birthday,LocalDate.now()).getYears();
    }

    public LocalDate getBirthday() {
        return birthday;
    }

    public void setBirthday(LocalDate birthday) {
        this.birthday = birthday;
        setAge(birthday);
    }

    public String getPhoneNum() {
        return phoneNum;
    }

    public void setPhoneNum(String phoneNum) {
        this.phoneNum = phoneNum;
    }

    public int getGroup() {
        return group;
    }

    public void setGroup(int group) {
        this.group = group;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", gender='" + gender + '\'' +
                ", age=" + age +
                ", birthday=" + birthday +
                ", phoneNum='" + phoneNum + '\'' +
                ", group=" + group +
                '}';
    }

    @Override
    public int compareTo(Student o) {
        return id.compareTo(o.id);
    }
}
